home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / Apple Game Sprockets / Headers / InputSprocketDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-16  |  6.2 KB  |  224 lines  |  [TEXT/CWIE]

  1. #ifndef __InputSprocketDriver__
  2. #define __InputSprocketDriver__
  3.  
  4.  
  5. /*
  6.  * InputSprocketDriver.h
  7.  *
  8.  * Copyright (c) Apple Computer 1995, 1996 All Rights Reserved
  9.  * 
  10.  */
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15.  
  16. #include "InputSprocket.h"
  17. #include <Types.h>
  18. #include <Icons.h>
  19. #include <Dialogs.h>
  20.  
  21. /*
  22.  *
  23.  * this function will plot on icon suite of the applications
  24.  *
  25.  */
  26.  
  27. OSErr ISpPlotAppIconSuite(const Rect *theRect,
  28.                     IconAlignmentType align, 
  29.                     IconTransformType transform, 
  30.                     short iconSuiteResourceId);
  31.  
  32. typedef enum
  33. {
  34.     kISpSelector_Init =1,
  35.     kISpSelector_Stop,
  36.     kISpSelector_GetSize,
  37.     kISpSelector_HandleEvent,
  38.     kISpSelector_Show,
  39.     kISpSelector_Hide,
  40.     kISpSelector_BeginConfiguration,
  41.     kISpSelector_EndConfiguration,
  42.     kISpSelector_GetIcon,
  43.     kISpSelector_GetState,
  44.     kISpSelector_SetState,
  45.     kISpSelector_Dirty,
  46.     kISpSelector_SetActive
  47. } ISpMetaHandlerSelector;
  48.  
  49.  
  50. /*
  51.  *
  52.  * typedefs for the function pointers the metahandler may return 
  53.  *
  54.  */
  55.  
  56.  // a generic driver function pointer
  57. typedef OSStatus (* ISpDriverFunctionPtr_Generic)(UInt32 refCon, ...);
  58.  
  59. // the meta handler pointer
  60. typedef ISpDriverFunctionPtr_Generic (* ISpDriverFunctionPtr_MetaHandler)(UInt32 refCon, ISpMetaHandlerSelector);
  61.  
  62. // the pointers you get through the meta handler
  63. typedef OSStatus (* ISpDriverFunctionPtr_Init)(UInt32 refCon, UInt32 count, ISpNeed needs[], ISpElementReference virtualElements[], 
  64.                 Boolean used[], OSType appCreatorCode, OSType subCreatorCode, 
  65.                 UInt32 stateLength, void *state);
  66. typedef OSStatus (* ISpDriverFunctionPtr_Stop)(UInt32 refCon);
  67. typedef OSStatus (* ISpDriverFunctionPtr_GetSize)(UInt32 refCon, Point *minimum, Point *best);
  68. typedef OSStatus (* ISpDriverFunctionPtr_HandleEvent)(UInt32 refCon, EventRecord *theEvent, Boolean *handled);
  69. typedef OSStatus (* ISpDriverFunctionPtr_Show)(UInt32 refCon, DialogPtr theDialog, short dialogItemNumber);
  70. typedef OSStatus (* ISpDriverFunctionPtr_Hide)(UInt32 refCon);
  71. typedef OSStatus (* ISpDriverFunctionPtr_BeginConfiguration)(UInt32 refCon, UInt32 count, ISpNeed needs[]);
  72. typedef OSStatus (* ISpDriverFunctionPtr_EndConfiguration)(UInt32 refCon, Boolean accept);
  73. typedef OSStatus (* ISpDriverFunctionPtr_GetIcon)(UInt32 refCon, short *iconSuiteResourceId);
  74. typedef OSStatus (* ISpDriverFunctionPtr_GetState)(UInt32 refCon, UInt32 buflen, void *buffer, UInt32 *length);
  75. typedef OSStatus (* ISpDriverFunctionPtr_SetState)(UInt32 refCon, UInt32 length, void *buffer);
  76. typedef OSStatus (* ISpDriverFunctionPtr_Dirty)(UInt32 refCon, Boolean *dirty);
  77. typedef OSStatus (* ISpDriverFunctionPtr_SetActive)(UInt32 refCon, Boolean active);
  78.  
  79. // ********************* driver level functions *********************
  80.  
  81.  
  82. /*
  83.  *
  84.  * ISpDevice_New
  85.  *
  86.  * This creates a new device from the device definition structure and returns
  87.  * the result into the device reference.
  88.  *
  89.  * Returns Codes
  90.  * paramErr
  91.  * out of memory
  92.  * 
  93.  * Specical Considerations
  94.  * may not be done at interrupt time
  95.  */
  96.  
  97. OSStatus ISpDevice_New(    const ISpDeviceDefinition *inStruct, 
  98.                         ISpDriverFunctionPtr_MetaHandler metaHandler, 
  99.                         UInt32 refCon, 
  100.                         ISpDeviceReference *outReference);
  101.  
  102. /*
  103.  * ISpDevice_Dispose
  104.  *
  105.  * This disposes an existing device.
  106.  *
  107.  * Returns Codes
  108.  * paramErr
  109.  *
  110.  * Special Considerations
  111.  * May not be done at interrupt time
  112.  *
  113.  */
  114.  
  115. OSStatus ISpDevice_Dispose(ISpDeviceReference inReference);
  116.  
  117.  
  118. /*
  119.  *
  120.  * ISpElementDefinitionStruct
  121.  *
  122.  * This is the structure that defines everything static about this
  123.  * element.  For each element on your device you will need to 
  124.  * fill in one of these structures when your driver loads.
  125.  *
  126.  */
  127.  
  128. typedef struct ISpElementDefinitionStruct
  129. {
  130.     ISpDeviceReference device;  // device this element belongs to
  131.     UInt32 group;             // group this element belongs to or 0
  132.     
  133.     Str63 theString;         // a string that is a human readable identifier for this element, internationalization ?
  134.         
  135.     ISpElementKind kind;        
  136.     ISpElementLabel label;        
  137.     
  138.     void *configInfo;         // a pointer to the buffer containing the configuration information for this element
  139.     UInt32 configInfoLength; // length of that configuration info
  140.  
  141.     UInt32 dataSize;         // the size of the data, so we can generate an appropriate buffer
  142.     
  143.     UInt32 reserved1;
  144.     UInt32 reserved2;
  145.     UInt32 reserved3;
  146. } ISpElementDefinitionStruct;
  147.  
  148. /*
  149.  *
  150.  * ISpElement_New
  151.  *
  152.  * ISpElement_New takes an element definition struct and gives you back a element reference.
  153.  * When you produce data you use that element reference to give the data to the system.
  154.  * 
  155.  * Return Codes
  156.  * paramErr
  157.  * memory error
  158.  *
  159.  * Special Considerations
  160.  * The ISpElement_New function may move or purge memory.  Your application should not call this function 
  161.  * at interrupt time.
  162.  * 
  163.  */
  164.  
  165. OSStatus ISpElement_New(const ISpElementDefinitionStruct *inStruct, ISpElementReference *outElement);
  166.  
  167. /*
  168.  *
  169.  * ISpElement_Dispose
  170.  *
  171.  * ISpElement_Dispose takes an element reference and deletes it.
  172.  * You should call this function when your driver unloads.
  173.  *
  174.  * Return Codes
  175.  * paramErr
  176.  * memory error
  177.  *
  178.  * Special Considerations
  179.  * The ISpElement_Dispose function may move or purge memory.  Your application should not call this function 
  180.  * at interrupt time.
  181.  * 
  182.  */
  183.  
  184. OSStatus ISpElement_Dispose(ISpElementReference inElement);
  185.  
  186. /*
  187.  *
  188.  * ISpElement_PushSimpleData
  189.  *
  190.  * ISpElement_PushSimpleData is the appropriate way to give the system data if your data fits exactly into
  191.  * a 32 bit signed number.  You pass the element reference that goes with the data, the data and the 
  192.  * AbsoluteTime that data was produced.  If UpTime is not available you should fill time.lo with the
  193.  * TickCount time and time.hi with 0.
  194.  *
  195.  * Return Codes
  196.  * paramErr
  197.  *
  198.  */
  199.  
  200. OSStatus ISpElement_PushSimpleData(ISpElementReference inElement, UInt32 data, const AbsoluteTime *time);
  201.  
  202. /*
  203.  *
  204.  * ISpElement_PushComplexData
  205.  *
  206.  * ISpElement_PushComplexData is exactly like ISpElement_PushSimpleData except that it is appropriate for times
  207.  * when your data does not fit into a signed 32 bit integer.
  208.  *
  209.  * Instead it takes the length of your data (which must match the datasize field of your ISpElementDefinitionStruct)
  210.  * and a ptr to the devices state.
  211.  *
  212.  * Return Codes
  213.  * paramErr
  214.  *
  215.  */
  216.  
  217. OSStatus ISpElement_PushComplexData(ISpElementReference inElement, UInt32 buflen, void *state, const AbsoluteTime *time);    
  218.  
  219.  
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223.  
  224. #endif // __InputSprocketDriver__